package cn.chrisn.componenthub.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
import java.util.logging.LogRecord;

/**
 * @Description
 * @Author Chrisn
 * @Date 2025/5/3
 */
@WebFilter(urlPatterns = "/*")
public class DemoFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("DemoFilter,init初始化方法执行了");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("DemoFilter,拦截到请求,执行放行前的逻辑");
        filterChain.doFilter(servletRequest,servletResponse);

        System.out.println("DemoFilter,执行放行后的逻辑");
    }

    @Override
    public void destroy() {
        System.out.println("DemoFilter,destroy 销毁方法执行了");
    }
}
